package GUI窗体和Swing.事件处理机制.Swing常用事件处理;

import javax.swing.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

//鼠标事件处理
public class text2 {
    public static void main(String[] args) {
        JFrame jf = new JFrame();
        jf.setTitle("鼠标事件处理");
        jf.setBounds(100,100,400,300);
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jf.setVisible(true);
        JButton jb = new JButton("按钮");
        jf.add(jb);

        jb.addMouseListener(new MouseListener() {
          public void mouseClicked(MouseEvent e) {
              System.out.println("鼠标点击");
          }
          public void mousePressed(MouseEvent e) {
              System.out.println("鼠标按下");
          }
          public void mouseReleased(MouseEvent e) {
              System.out.println("鼠标释放");
          }
          public void mouseEntered(MouseEvent e) {
              System.out.println("鼠标进入");
          }
          public void mouseExited(MouseEvent e) {
              System.out.println("鼠标退出");
          }
          public void mouseDragged(MouseEvent e) {
              System.out.println("鼠标拖动");
          }
          public void mouseclick(MouseEvent e) {
              System.out.println("鼠标点击");
          }


        });

    }
}
